
import java.io.IOException;

import javax.microedition.lcdui.*;
import javax.microedition.midlet.MIDlet;

public class HelicopterMidlet extends MIDlet implements CommandListener, DisplayController {

    private HelicopterCanvas m_HelicopterCanvas;
    private Display m_display;
    private Alert m_Alert = null;
    private Command exitCommand = null;
   
    public void startApp() {
//        if (m_HelicopterCanvas == null) {
//            try {
//                m_HelicopterCanvas = new HelicopterCanvas();
//                m_HelicopterCanvas.start();
//                exitCommand = new Command("Exit", Command.EXIT, 0);
//                m_HelicopterCanvas.addCommand(exitCommand);
//                m_HelicopterCanvas.setCommandListener(this);
//                
//            } catch (IOException ioe) {
//                System.out.println(ioe);
//            }
//        }

    	m_display = Display.getDisplay(this);
    	
    	
    	GameModeForm gmf = new GameModeForm(this);
    	m_display.setCurrent(gmf);

//        Display.getDisplay(this).setCurrent(m_HelicopterCanvas);

    }

 
    public void createAlert() {
        m_Alert.setTimeout(Alert.FOREVER);
        if (m_Alert != null) {
            m_display.setCurrent(m_Alert);

        }
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
        if (m_HelicopterCanvas != null) {

            m_HelicopterCanvas.stopHelicopter();
        }
    }

    public void commandAction(Command c, Displayable s) {
        if (c.getCommandType() == Command.EXIT) {
            destroyApp(true);
            notifyDestroyed();
        }

    }


	public void setCurrentDisplay(Displayable d) {
		m_display.setCurrent(d);
	}
}
